<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box">
        <a href="/home">首页</a>
        <a href="/service">设置</a>
        <a href="/mine">用户</a>
    </div>
    <div class="banner"></div>
</body>

</html>
<script>
//history路由

    var as = document.querySelectorAll('a')
    as.forEach((item,index) => {
        item.onclick = function (e) {
            e.preventDefault()
            
            history.pushState( {} , '' , this.href );
            // console.log(location)
            switch (location.pathname) {
                case '/home': shouye(); break;
                case '/service': shezhi(); break;
                case '/mine': yonghu(); break;
            }

        }

    })

    function shouye() {
        document.querySelector('.banner').innerHTML = '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊'
    }
    function shezhi() {
        document.querySelector('.banner').innerHTML = '哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈'
    }
    function yonghu() {
        document.querySelector('.banner').innerHTML = '呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵'
    }
</script>